﻿using System;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.SharePoint.Client;
using SP = Microsoft.SharePoint.Client;
using System.Collections.ObjectModel;
using System.Xml.Linq;
using System.IO.IsolatedStorage;
using System.IO;
using System.Runtime.Serialization;
using System.Text;
using System.Collections.Generic;
using System.Windows.Threading;



namespace UI
{
    /*public class Campus
    {
        public Campus(string name)
        {
            _name = name;
            _buildings = new List<Building>();
        }
        string _name;
        public string Name { get { return _name; } }
        List<Building> _buildings;
        public List<Building> Buildings { get { return _buildings; } }
    }*/
    public class Building
    {
        public Building(string name)
        {
            _name = name;
            _floors = new List<Floor>();
        }
        public Building(string name, string image)
        {
            _name = name;
            _image = image;
            _floors = new List<Floor>();
        }
        string _name;
        string _image;
        public string Name { get { return _name; } }
        public string Image { get { return _image; } }
        List<Floor> _floors;
        public List<Floor> Floors { get { return _floors; } }
    }
    public class Floor
    {
        public Floor(string name, string image)
        {
            _name = name;
            this.image = image;
        }
        string _name;
        string image;
        public string Name { get { return _name; } }
        public string Image { get { return image; } }
    }
    public class TreeDataSource : List<Building>
    {



        public TreeDataSource(ListItemCollection allCampus)
        {
            //Campus c;
            Building b = new Building("");
            List<string> titles;
            titles = new List<string>();

            foreach (ListItem item in allCampus)
            {
                if (!titles.Contains(item["Building"].ToString()))
                {
                    titles.Add(item["Building"].ToString());
                }

            }
            foreach (string str in titles)
            {

                //Add(c = new Campus(str));

                /*foreach (ListItem item in allCampus)
                {
                   if (item["Campus"].ToString().Equals(str)&&!buildings.Contains(item["Building"].ToString())){
                       buildings.Add(item["Building"].ToString());
                   }
                }*/
                // foreach (string strng in buildings)
                // {
                b = new Building(str);
                foreach (ListItem item in allCampus)
                {
                    if (item["Building"].ToString().Equals(str))
                    {
                        if (item["Floor"].ToString().Equals("0"))
                        {
                            b.Floors.Add(new Floor("Floor 1", item["Building"].ToString()));
                        }
                        else
                        {
                            b.Floors.Add(new Floor("Floor " + item["Floor"].ToString(), item["Building"].ToString() + " Floor " + item["Floor"].ToString()));
                        }
                    }
                }
                //}
            }

        }
    }
}
